<?php

namespace App\Listeners;

use Illuminate\Database\Events\QueryExecuted;

class SqlListener {
	/**
	 * Create the event listener.
	 *
	 * @return void
	 */
	public function __construct() {
		//
	}

	/**
	 * Handle the event.
	 *
	 * @param  QueryExecuted  $event
	 * @return void
	 */
	public function handle(QueryExecuted $event) {
		if (config('app.debug')) {
			$sql = str_replace("?", "'%s'", $event->sql);
			sqlLog($sql);
			sqlLog($event->bindings);
			sqlLog('----------------------------------------------');
		}
	}
}
